

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>表单组合</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="__STATIC__/layuikn/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="__STATIC__/layuikn/style/admin.css" media="all">
</head>

<style>
    #zyzlzd .layui-form-checkbox{
        margin-top: 10px;
    }
</style>

<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header"><h2>卡氏评分</h2></div>
        <div class="layui-card-body" style="padding: 15px;">
            <fieldset class="layui-elem-field" style="padding: 20px;">
                <legend style="font-size: 15px;">个人信息</legend>
                <div class="layui-row">
                    <div class="layui-col-md4">住院号：<span id="huanzhe_hospital_id"></span></div>
                    <div class="layui-col-md4">姓名：<span id="huanzhe_name"></span></div>
                    <div class="layui-col-md4">性别：<span id="huanzhe_gender"></span></div>
                </div>
                <div class="layui-row">
                    <div class="layui-col-md4">科室：<span id="huanzhe_keshi"></span></div>
                    <div class="layui-col-md4">年龄：<span id="huanzhe_age"></span></div>
                    <div class="layui-col-md4">录入日期：<span id="huanzhe_created"></span></div>
                </div>
            </fieldset>
            <form class="layui-form" action="" lay-filter="component-form-group">
                <fieldset class="layui-elem-field" style="padding: 20px;">
                    <legend style="font-size: 15px;">卡氏评分（KPS分级）</legend>
                    <div class="layui-row">
                        健康状况自我评分标准（KPS评分标准）   得分： <span id="score"></span>分
                    </div>
                    <div class="layui-row" id="score_list">
                        <div class="layui-col-md12">
                            <input type="radio" name="kps_id" value="100" title="100分 身体正常，无任何不适">
                        </div>
                        <div class="layui-col-md12">
                            <input type="radio" name="kps_id" value="男" title="男">
                        </div>
                    </div>
                    <div class="layui-row">
                        注：得分越高，健康状况越好，越能忍受治疗给身体带来的副作用，因而也就有可能接受彻底的治疗。得分越低，健康状况越差，若低于60分，许多有效的抗肿瘤治疗即无法实施。
                    </div>

                </fieldset>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="last">上一步</button>
                            <button class="layui-btn" lay-submit="" lay-filter="next">下一步</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>

</div>


<script src="__STATIC__/layuikn/layui/layui.js"></script>
<script>
    layui.config({
        base: '__STATIC__/layuikn/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
        ,ajaxData:'../extends/ajaxData'
        ,getOption:'../extends/getOption'
    }).use(['index', 'jquery', 'ajaxData', 'getOption', 'form', 'laydate'], function(){
        var $ = layui.$
            ,admin = layui.admin
            ,element = layui.element
            ,layer = layui.layer
            ,laydate = layui.laydate
            ,ajaxData = layui.ajaxData
            ,getOption = layui.getOption
            ,form = layui.form;

        var pid = sessionStorage.getItem('pid');
        ajaxData.ajaxData('GET',"{:url('patient/info')}?pid=" + pid,{},function (back) {
            var score = '';
            if(back.data){
                $('#huanzhe_hospital_id').html(back.data.hospital_id);
                $('#huanzhe_name').html(back.data.name);
                $('#huanzhe_gender').html(back.data.gender);
                $('#huanzhe_keshi').html(back.data.keshi);
                $('#huanzhe_age').html(back.data.age);
                $('#huanzhe_created').html(back.data.created);
                score = back.data.kps_id;
            }
            $('#score').html(score);
            var html = '';
            $.each(score_list,function (k,v) {
                html += '<div class="layui-col-md12">\n' +
                    '        <input type="radio" name="kps_id" lay-filter="kps_id" ' + isSelected(score,v.value) +  ' value="' + v.value + '" title="' + v.title + '">\n' +
                    '    </div>';
            });
            $('#score_list').html(html);
            form.render();
        });

        function isSelected(score,value) {
            if(score == value){
                return 'checked';
            }
        }
        var score_list = [
            {'value':100, 'title':'100分 身体正常，无任何不适'},
            {'value':90, 'title':'90分 能进行正常活动，有轻微不适'},
            {'value':80, 'title':'80分 勉强可进行正常活动，有一些不适'},
            {'value':70, 'title':'70分 生活可自理，但不能维持正常生活或工作'},
            {'value':60, 'title':'60分 有时需人扶助，但大多数时间可自理'},
            {'value':50, 'title':'50分 常需人照料'},
            {'value':40, 'title':'40分 生活不能自理，需特别照顾'},
            {'value':30, 'title':'30分 生活严重不能自理'},
            {'value':20, 'title':'20分 病重，需住院积极支持治疗'},
            {'value':10, 'title':'10分 病危，临近死亡'},
            {'value':0, 'title':'0分 死亡'}
        ]

        form.on('radio(kps_id)',function (data) {
            $('#score').html(data.value);
        });
        form.on('submit(last)',function(data){
            if(pid == 'null') return  false;
            window.location.href = "{:url('jibing/show')}";
            return  false;
        });
        /* 监听提交 */
        form.on('submit(next)', function(data){
           if(pid == 'null') return  false;
            ajaxData.ajaxData('POST', "{:url('kspf/update')}?pid=" + pid, data.field,function (back) {
                if(back.code == 200){
                    window.location.href = "{:url('shiyanshi/show')}";
                }else{
                    layer.msg(back.msg, {icon: 5});
                }
            });
            // parent.layer.alert(JSON.stringify(data.field), {
            //     title: '最终的提交信息'
            // })
            return false;
        });

    });
</script>
</body>
</html>
